#!/usr/bin/env python3
"""Verify that all GA artifacts got pushed."""

import os.path
import sys
import argparse

from lib import check_artifacts, re_ga, re_ea

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description='Edit image values for ambassador helm charts.')
    parser.add_argument('--no-docker', dest='docker', default=True, action='store_false')
    parser.add_argument('--promote-path', default="")
    parser.add_argument('--ga-version', required=True)
    parser.add_argument('--chart-version', required=True)
    parser.add_argument('--source-registry', default='docker.io/datawire')
    parser.add_argument('--image-name', default='emissary')
    parser.add_argument('--image-append', default='')
    args = parser.parse_args()

    include_docker = True
    ga_ver = args.ga_version
    chart_ver = args.chart_version

    if not re_ga.match(ga_ver) and not re_ea.match(ga_ver):
        sys.stderr.write(f"{ga_ver} does not match X.Y.Z(-ea)?")
        sys.exit(2)

    if not re_ga.match(chart_ver) and not re_ea.match(chart_ver):
        sys.stderr.write(f"{chart_ver} does not match X.Y.Z(-ea)?")
        sys.exit(2)

    sys.exit(check_artifacts.main(ga_ver=ga_ver, chart_ver=chart_ver,
        include_docker=args.docker, release_channel=args.promote_path,
        source_registry=args.source_registry, image_append=args.image_append, image_name=args.image_name))
